# Scripts that Clean the LBD Data

This folder includes scripts that clean the LBD data. The sequence of scripts indicate potential dependency. 
* \* denotes important scripts.

## Main Update

* 2020-12-22: Updated `lbd_0_ch_ind.sas` and `lbd_2_clean.sas` to include latest data. Changed a merge in `lbd_0_ch_ind.sas` (inconsequential).
* 2020-12-24: Updated `lbd_1_raw.sas` and changed how missing firmnum is imputed from cfn based on the LBD documentation. The change is inconsequential.

## General Purpose Scripts

| Script | Description |
|:---------|:---------|
| `lbd_0_m_lbd_basic.sas`* | Script that conducts basic cleaning (e.g. improving firmnum, fips). |
| `lbd_0_ch_ind.sas`* | Script that assigns industry classification that we define (named ch_ind) to each establishment. |
| `lbd_m_merge_runif.sas`* | Merging with random numbers (generated by `lbd_2_runif.sas`). |
| `lbd_m_merge_ch_ind_sect.sas`* | Merge with sector codes. |
| ` ` | |

## Scripts for Final Production

| Script | Description |
|:---------|:---------|
| `lbd_1_raw.sas`* | Reads in the main LBD data and fk_naics codes. No data manipulation happens. |
| `lbd_1_raw_fk_flag.sas` | Reads in the fk_naics flag variable. |
| `lbd_1_raw_fk_aux.sas` | fk-auxiliary for SIC years. |
| `lbd_2_runif.sas`* | Generates 2 random numbers for each establishments that are later used when breaking ties etc. |
| `lbd_2_clean.sas`* | Generates clean LBD data (including merging with improved industry codes and MSA codes). This script calls `lbd_0_m_lbd_basic.sas` and `lbd_0_ch_ind.sas`. |
| ` ` | |
